package blog;

public class User {
    public int id;
    public String nickname;
    public String username;
    //当前的登录用户信息
    //如果没有登录 user==null，否则，指向具体的用户对象
    private static User currentUser = null;

    public static void login(User user) {
        currentUser = user;
        System.out.println("刚登录的用户信息是" + currentUser);
    }

    public static User getCurrentUser() {
        return currentUser;
    }

    public static boolean isLogined() {
        return currentUser != null;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", nickname='" + nickname + '\'' +
                ", username='" + username + '\'' +
                '}';
    }
}
